﻿using Microsoft.Win32;
using MM.Common.DBBase;
using System;
using System.Management;
using System.Windows.Forms;

namespace MM.Common.Base
{
    public static class SystemInfo
    {
        // Fields
        public static int AntibioticLevels;
        public static string CityCode;
        private static string computerID;
        private static string computerIp;
        private static string computerName;
        private static string copyWrite;
        public static string CountyCode;
        private static DbBase dbData;
        public static string empKindId;
        private static DateTime lastDate;
        private static MessageServer messageDataServer;
        public static bool Narcotic = false;
        private static string operCode;
        private static int operDepartId;
        private static string operDepartName;
        private static int operGroupId;
        private static string operGroupName;
        private static int operId;
        private static string operInputCode;
        private static bool operIsAdmin;
        private static bool operIsDoctor;
        private static string operName;
        private static string operRoleList;
        private static string orgHeadCode;
        private static string orgHeadName;
        private static string orgSubCode;
        private static string orgSubName;
        public static bool Poison = false;
        public static string Prescription;
        public static string ProvinceCode;
        public static bool Psychotropic = false;
        private static QueryReportServer reportDataServer;
        private static string runFile;
        private static string runPath;
        public static bool SkinTest = false;
        private static string systemCode;
        private static string systemName;
        public static string TownCode;

        // 目前只有SQL SERVER
        public static void SetDBBase(string dbname)
        {
            switch (dbname)
            {
                case "SQL SERVER":
                    dbData = new DbSqlData();
                    return;
            }
        }

        public static void SetSystemInfo(string dbname)
        {
            OperId = -1;
            SetDBBase(dbname);
            computerID = "90FBA603D2AF";
            reportDataServer = new QueryReportServer();
            MessageDataServer = new MessageServer();
        }

        // Properties
        public static string ComputerID
        {
            get
            {
                return computerID;
            }
            set
            {
                computerID = value;
            }
        }

        public static string ComputerIp
        {
            get
            {
                return computerIp;
            }
            set
            {
                computerIp = value;
            }
        }

        public static string ComputerName
        {
            get
            {
                return computerName;
            }
            set
            {
                computerName = value;
            }
        }

        public static string CopyWrite
        {
            get
            {
                return copyWrite;
            }
            set
            {
                copyWrite = value;
            }
        }

        public static DbBase DbData
        {
            get
            {
                return dbData;
            }
        }

        public static string EmpKindId
        {
            get
            {
                return empKindId;
            }
            set
            {
                empKindId = value;
            }
        }

        public static DateTime LastDate
        {
            get
            {
                return lastDate;
            }
            set
            {
                lastDate = value;
            }
        }

        public static MessageServer MessageDataServer
        {
            get
            {
                return messageDataServer;
            }
            set
            {
                messageDataServer = value;
            }
        }

        public static string OperCode
        {
            get
            {
                return operCode;
            }
            set
            {
                operCode = value;
            }
        }

        public static int OperDepartId
        {
            get
            {
                return operDepartId;
            }
            set
            {
                operDepartId = value;
            }
        }

        public static string OperDepartName
        {
            get
            {
                return operDepartName;
            }
            set
            {
                if (value == null)
                {
                    operDepartName = "";
                }
                else
                {
                    operDepartName = value;
                }
            }
        }

        public static int OperGroupId
        {
            get
            {
                return operGroupId;
            }
            set
            {
                operGroupId = value;
            }
        }

        public static string OperGroupName
        {
            get
            {
                return operGroupName;
            }
            set
            {
                operGroupName = value;
            }
        }

        public static int OperId
        {
            get
            {
                return operId;
            }
            set
            {
                operId = value;
            }
        }

        public static string OperInputCode
        {
            get
            {
                return operInputCode;
            }
            set
            {
                operInputCode = value;
            }
        }

        public static bool OperIsAdmin
        {
            get
            {
                return operIsAdmin;
            }
            set
            {
                operIsAdmin = value;
            }
        }

        public static bool OperIsDoctor
        {
            get
            {
                return operIsDoctor;
            }
            set
            {
                operIsDoctor = value;
            }
        }

        public static string OperName
        {
            get
            {
                return operName;
            }
            set
            {
                operName = value;
            }
        }

        public static string OperRoleList
        {
            get
            {
                return operRoleList;
            }
            set
            {
                operRoleList = value;
            }
        }

        public static string OrgHeadCode
        {
            get
            {
                return orgHeadCode;
            }
            set
            {
                if ((orgHeadCode == null) || (orgHeadCode == ""))
                {
                    orgHeadCode = value;
                }
            }
        }

        public static string OrgHeadName
        {
            get
            {
                return orgHeadName;
            }
            set
            {
                if (orgHeadName == null)
                {
                    orgHeadName = value;
                }
            }
        }

        public static string OrgSubCode
        {
            get
            {
                return orgSubCode;
            }
            set
            {
                if ((orgSubCode == null) || (orgSubCode == ""))
                {
                    orgSubCode = value;
                }
            }
        }

        public static string OrgSubName
        {
            get
            {
                return orgSubName;
            }
            set
            {
                if (orgSubName == null)
                {
                    orgSubName = value;
                }
            }
        }

        public static string OrgSubShortCode
        {
            get
            {
                if (orgHeadCode == OrgSubCode)
                {
                    return "00";
                }
                return orgSubCode.Substring(orgHeadCode.Length);
            }
        }

        public static QueryReportServer ReportDataServer
        {
            get
            {
                return reportDataServer;
            }
        }

        public static string RunFile
        {
            get
            {
                return runFile;
            }
            set
            {
                runFile = value;
            }
        }

        public static string RunPath
        {
            get
            {
                return runPath;
            }
            set
            {
                runPath = value;
            }
        }

        public static string SystemCode
        {
            get
            {
                return systemCode;
            }
            set
            {
                systemCode = value;
            }
        }

        public static string SystemName
        {
            get
            {
                return systemName;
            }
            set
            {
                systemName = value;
            }
        }
    }
}
